package com.pk.platform.business.apply.dao.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.pk.platform.business.apply.dao.IVacationDao;
import com.pk.platform.business.apply.vo.VacationVO;
import com.pk.platform.business.core.dao.impl.GenericDaoImpl;
import com.pk.platform.util.StringConverter;
import com.pk.platform.util.page.Pager;

public class VacationDaoImpl extends GenericDaoImpl implements IVacationDao {

	public List<Map<String, Object>> queryVacationList(VacationVO vvo, Pager pager) {
		StringBuffer sql = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		sql.append("select v.*, e.employeeNum, e.employeeName from b_vacation v left join d_employee e");
		sql.append(" on v.employeeId = e.id where 1 = 1");
		if(StringConverter.isNotNull(vvo.getEmployeeNum()))
		{
			sql.append(" and e.employeeNum like ?");
			param.add("%" + vvo.getEmployeeNum() + "%");
		}
		if(StringConverter.isNotNull(vvo.getEmployeeName()))
		{
			sql.append(" and e.employeeName like ?");
			param.add("%" + vvo.getEmployeeName() + "%");
		}
		return super.getListByPage(sql.toString(), param.toArray(), pager);
	}
	
	public List<Map<String, Object>> queryTaskVacationList(VacationVO vvo, Pager pager) {
		StringBuffer sql = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		sql.append("select v.*, e.employeeNum, e.employeeName from b_vacation v left join d_employee e");
		sql.append(" on v.employeeId = e.id where 1 = 1");
		if(StringConverter.isNotNull(vvo.getEmployeeNum()))
		{
			sql.append(" and e.employeeNum like ?");
			param.add("%" + vvo.getEmployeeNum() + "%");
		}
		if(StringConverter.isNotNull(vvo.getEmployeeName()))
		{
			sql.append(" and e.employeeName like ?");
			param.add("%" + vvo.getEmployeeName() + "%");
		}
		return super.getTaskListByPage(sql.toString(), null, pager, "com.pk.platform.domain.apply.Vacation");
	}

}
